"""
listdir

相对路径-代码里面不会出现绝对路径
1、动态获取当前文件的绝对路径 - os.path.abspath(__file__)
2、动态活动所给目录/文件的所在目录 os.path.dirname(文件/目录)
3、动态拼接路径（根据操作系统处理路径拼接符-win \  linux /)   os.path.jion(顶级目录，追加在顶级目录之后的目录)

os.path模块工具链接https://www.runoob.com/python3/python3-os-chdir.html
"""

import os

# basedir = r"C:\Users\Mr MING\PycharmProjects\pythonProject1-编辑测试"
# files = os.listdir(r"C:\Users\Mr MING\PycharmProjects\pythonProject1-编辑测试")
# print(files)

# 怎么拼接路径
# for file in files:
#     print(basedir + "\\" + file)

# 1、动态获取当前文件的绝对路径
file_full_path = os.path.abspath(__file__)
print(file_full_path)

# 2、动态获取所给目录/文件 所在目录
flie_dir = os.path.dirname(file_full_path)
print(flie_dir)
#
porject_dir = os.path.dirname(flie_dir)
print(porject_dir)

# 3、得到数据类型的目录
# new_path = os.path.join(porject_dir, "python基础")
# print(new_path)
#
# new_path = os.path.join(porject_dir, "python基础", "数据类型.py")
# print(new_path)

